package com.simple.datax;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Date;

public class LocalFileSimulator {
	public static void main(String[] args) {
		File file = new File("D:\\Java\\workspace\\EC\\import_file");
		File tempFile = null;
		File fileCopy = new File("D:\\Java\\workspace\\EC\\import_file\\EC7617257780.xml");
		if (file.isDirectory()) {
			for (int i = 1; i < 100; i++) {
				tempFile = new File(file.getPath() + File.separator + "test_input_" + i);
				tempFile.mkdirs();
				for (int j = 1; j<10; j++) {
					try {
						forJava(fileCopy, new File(tempFile+File.separator+j+".xml"));
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
			
//			for (int i = 1; i < 100; i++) {
//				tempFile = new File(file.getPath() + File.separator + i + "_Sender");
//				tempFile.mkdirs();
////				for (int j = 1; j<10; j++) {
////					try {
////						forJava(fileCopy, new File(tempFile+File.separator+j+".txt"));
////					} catch (Exception e) {
////						e.printStackTrace();
////					}
////				}
//			}
		} else {
			System.out.println("It's not directory.");
		}
	}

	public static long forJava(File f1, File f2) throws Exception {
		long time = new Date().getTime();
		int length = 2097152;
		FileInputStream in = new FileInputStream(f1);
		FileOutputStream out = new FileOutputStream(f2);
		byte[] buffer = new byte[length];
		while (true) {
			int ins = in.read(buffer);
			if (ins == -1) {
				in.close();
				out.flush();
				out.close();
				return new Date().getTime() - time;
			} else
				out.write(buffer, 0, ins);
		}
	}
}
